import request from '@/utils/request'

/**
 * 查询列表
 * @param query
 * @returns {AxiosPromise<AxiosResponse<any>>}
 */
export function list(query) {
  return request({
    url: '/finance/complete/list',
    method: 'get',
    params: query
  })
}

// 批量删除接口
export function delAll(ids) {
  const idArray = Array.isArray(ids) ? ids : [ids];
  return request({
    url: '/finance/complete/' + idArray.join(','),
    method: 'delete'
  })
}


// 查询详情接口
export function get(id) {
  return request({
    url: '/finance/complete/' + id,
    method: 'get'
  })
}

//更新接口
export function update(data) {
  // 更严格的ID验证
  if (data.id === undefined || data.id === null || isNaN(Number(data.id)) || data.id <= 0) {
    return Promise.reject(new Error('ID不能为空且必须为正整数'));
  }

  return request({
    url: '/finance/complete/' + data.id,
    method: 'put',
    data: data
  })
}

//添加接口
export function add(data) {
  return request({
    url: '/finance/complete',
    method: 'post',
    data: data
  })
}

// 添加批量导入接口
export function importData(data) {
  return request({
    url: '/tms/complete/import',
    method: 'post',
    data: data
  })
}
